public class wxd{

	public static void main(String[] args){
 		int[] arr = new int[]{-4, 1, 2, 2, 5, 5, 5, 8, 10};
 		int t = 6;
 		int num = binarySearch(arr, -5);
 		System.out.println("小于" + t + "的最后一个数的下标是" + num);

	}
	
	private static int binarySearch(int[] arr, int t){
		int low = 0;
		int high = arr.length - 1;
		while(low <= high){
			int mid = (low + high)/2;
			if(arr[mid] > t){
				high = mid - 1;
			}else{
				low = mid + 1;
			}
		}
		return low -1;
	}
}
